package com.donfu.system.service.house.impl;

import java.util.List;
import com.donfu.common.utils.DateUtils;
import com.donfu.system.domain.house.HouseCart;
import com.donfu.system.mapper.house.HouseCartMapper;
import com.donfu.system.service.house.IHouseCartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 购物车Service业务层处理
 * 
 * @author donfu
 * @date 2021-12-07
 */
@Service
public class HouseCartServiceImpl implements IHouseCartService
{
    @Autowired
    private HouseCartMapper houseCartMapper;

    /**
     * 查询购物车
     * 
     * @param id 购物车主键
     * @return 购物车
     */
    @Override
    public HouseCart selectHouseCartById(Long id)
    {
        return houseCartMapper.selectHouseCartById(id);
    }

    /**
     * 查询购物车列表
     * 
     * @param houseCart 购物车
     * @return 购物车
     */
    @Override
    public List<HouseCart> selectHouseCartList(HouseCart houseCart)
    {
        return houseCartMapper.selectHouseCartList(houseCart);
    }

    /**
     * 新增购物车
     * 
     * @param houseCart 购物车
     * @return 结果
     */
    @Override
    public int insertHouseCart(HouseCart houseCart)
    {
        return houseCartMapper.insertHouseCart(houseCart);
    }

    /**
     * 修改购物车
     * 
     * @param houseCart 购物车
     * @return 结果
     */
    @Override
    public int updateHouseCart(HouseCart houseCart)
    {
        houseCart.setUpdateTime(DateUtils.getNowDate());
        return houseCartMapper.updateHouseCart(houseCart);
    }

    /**
     * 批量删除购物车
     * 
     * @param ids 需要删除的购物车主键
     * @return 结果
     */
    @Override
    public int deleteHouseCartByIds(Long[] ids)
    {
        return houseCartMapper.deleteHouseCartByIds(ids);
    }

    /**
     * 删除购物车信息
     * 
     * @param id 购物车主键
     * @return 结果
     */
    @Override
    public int deleteHouseCartById(Long id)
    {
        return houseCartMapper.deleteHouseCartById(id);
    }

    @Override
    public int emptyCart(Long userId) {
        return houseCartMapper.emptyCart(userId);
    }
}
